<?php

namespace app\common\model;

use think\Model;
use think\Request;
use think\Db;
class HuiYuanSupervise extends Model
{
	protected function initialize()
	{
		parent::initialize();
	}
	public function memberList($where,$w,$limit){
		return HuiYuanSupervise::name('username')
				->alias('a')
				->field(['a.id as uid','a.zcjje as zcjje','a.reg_je as reg_je','a.username as username','a.login_num','a.cz_num','a.tx_num','a.dl as dl','a.je as je','a.open as open','a.reg_time as reg_time','a.khd as khd','a.login_time as login_time','a.login_ip as login_ip','a.czzje as czzje','a.txzje as txzje','a.tzzje as tzzje','a.tjr as tjr','a.beizhu as beizhu','a.nbzh as nbzh','a.reg_ip as reg_ip','a.bankname as bankname'])
				->join('__US_CLASS__ b','b.id=a.us_class')
				->field(['b.class_name as hy_name'])
				->where('a.sales',0)
				->where($where)->where($w)->order('a.id desc')
				->paginate($limit,false,['query'=>request()->param()]);
	}
	
	public function SaveUpdate($sql,$where,$data){
		return HuiYuanSupervise::name($sql)->where($where)->update($data);
	}
	public function InsertAdd($sql,$data){
		return HuiYuanSupervise::name($sql)->insert($data);
	}
	public function memberDelete($sql,$where)
	{
		return HuiYuanSupervise::name($sql)->where($where)->delete();
	}
	public function dlSelect($sql,$where,$limit){
		return HuiYuanSupervise::name($sql)->where($where)->order('id desc')->paginate($limit,false,['query'=>request()->param()]);
	}
	public function caozuorizhi_xieru($caozuo){
        $user=input('cookie.user');
        if($user){
            $request = Request::instance();
            $ip=$request->ip();
            $arr=array('rz_class'=>1,'rz_test'=>$caozuo,'rz_time'=>time(),'rz_ip'=>$ip,'rz_user'=>$user,'client'=>1);
        	return  Db::name('rizhi_jl')->insert($arr);
        }
    }
}